package com.basic.udp;

import java.io.IOException;
import java.net.*;

/**
 * @Description:
 * @Date: 2024-03-28 09:04
 * @Author: wz
 **/
public class UdpSender {

    public static void main(String[] args) throws IOException {
        InetAddress ip = InetAddress.getByName("127.0.0.1");
        DatagramSocket socket = new DatagramSocket();
//        socket.connect(ip,9099);
        String msg = "hello,握手吧";
        byte[] bytes = msg.getBytes();
        DatagramPacket dp = new DatagramPacket(bytes,0,bytes.length,ip,9099);
        dp.setData(bytes);
        socket.send(dp);
        socket.close();
    }
}
